import sys
import os
import logging

logging.basicConfig(level=logging.INFO)

cur_file_path, filename = os.path.split(os.path.abspath(__file__))
sys.path.append(f"{cur_file_path}/../")

from l0n0lnet.socks import socks5_server
from l0n0lnet.transform import trans_server
from l0n0lnet import run, add_quit_func
from l0n0lnet.stream_parser import stream_parser

keys = [
    stream_parser.gen_password(),
    stream_parser.gen_password()
]
socks5 = socks5_server(b'127.0.0.1', 9997)
ts = trans_server(b'127.0.0.1', 9998, b'127.0.0.1', 9997, keys, 'server')
tc = trans_server(b'127.0.0.1', 9999, b'127.0.0.1', 9998, keys, 'client')


def on_close():
    ts.close()
    tc.close()
    socks5.close()
    print("closing")

add_quit_func(on_close)

run()